package com.youge.springbootdubboconsumer.controller;

import com.youge.gmall.bean.UserAddress;
import com.youge.gmall.service.OrderService;
import com.youge.gmall.service.UserService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: hcf
 * @qq: 46914685
 * @email: 46914685@qq.com
 * @date: 2020-10-18 2:42
 */

@RestController
@RequestMapping("/order")
public class OrderController {

//    @Autowired
//    private OrderService orderService;
//
//    @GetMapping("/initOrder")
//    public List<UserAddress> initOrder(@RequestParam("uid") String userId) {
//        System.out.println("ddsdsd");
//        return orderService.initOrder(userId);
//    }

    @DubboReference(version = "*")//version值为*,表示随机调用版本
    private UserService userService;

    @DubboReference(version = "0.0.1",stub = "com.youge.springbootdubboconsumer.service.impl.UserServiceStub")//version值为*,表示随机调用版本;stub 本地存根
    private UserService userService1;

    @GetMapping("/initOrder")
    public List<UserAddress> initOrder(@RequestParam(value = "uid",defaultValue = "1") String userId) {
        System.out.println("ddsdsd");
        List<UserAddress> userAddressList = userService.getUserAddressList(userId);
        return userAddressList;
    }

    @GetMapping("/initOrder1")
    public List<UserAddress> initOrder1(@RequestParam(value = "uid",defaultValue = "1") String userId) {
        System.out.println("ddsdsd");
        List<UserAddress> userAddressList = userService1.getUserAddressList(userId);
        return userAddressList;
    }

    @GetMapping("/index")
    public String index() {
        System.out.println("dsdsd");
        return "order/index";
    }
}
